﻿using System;
using ManagerClient.Authentification.Logic;
using ManagerClient.Manage.Logic;
using Microsoft.Practices.Unity;

namespace ManagerClient.Container
{
    public class Container
    {
        public static readonly Container Instance = new Container();

        private readonly IUnityContainer unityContainer;

        private Container()
        {
            unityContainer = new UnityContainer().
                RegisterType<LoginWindowViewModel>("LoginWindowViewModel", new ContainerControlledLifetimeManager()).
                RegisterType<MailControlViewModel>("MailControlViewModel", new ContainerControlledLifetimeManager()).
                RegisterType<ManageMenuViewModel>("ManageMenuViewModel", new ContainerControlledLifetimeManager()).
                RegisterType<ManageDepositsViewModel>("ManageDepositsViewModel",
                                                      new ContainerControlledLifetimeManager()).
                RegisterType<MainViewModel>("MainViewModel", new ContainerControlledLifetimeManager()).
                RegisterType<UserWindowViewModel>("UserWindowViewModel", new ContainerControlledLifetimeManager());
        }

        public T GetInstance<T>()
        {
            return unityContainer.Resolve<T>();
        }

        public object GetInstance(Type t)
        {
            return unityContainer.Resolve(t);
        }
    }
}